package com.xpgk.mvc.ddc.fineRegistration;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Record;
import com.xpgk.annotation.Service;
import com.xpgk.constant.ConstantRender;
import com.xpgk.dto.RenderBean;
import com.xpgk.mvc.base.BaseService;
import com.xpgk.mvc.ddc.entity.Vehicle;
//import com.xpgk.mvc.ddc_hpdj.Vehicle;


@Service(name = FineRegistrationService.serviceName)
public class FineRegistrationService  extends  BaseService{
	
	@SuppressWarnings("unused")
	private static final Log log = Log.getLog(FineRegistrationService.class);
	public static final String serviceName = "fineRegistrationService";	
	
	/**
	 * 根据顾客（会员）编号，手机号，姓名查出顾客信息
	 */
	public Map<String, Object> getVehInfo(String sfzh, String lsh, String hphm) {

		String msg = ConstantRender.render_success_code;
		
		Map<String, Object> queryParam = new HashMap<String, Object>();
		queryParam.put("SFZMHM", sfzh);
		queryParam.put("LSH", lsh);
		queryParam.put("HPHM", hphm);
		

		List<Record> lis = find(Vehicle.sqlId_selVeh, queryParam);
		Map<String, Object> mm = new HashMap<>();
		if (lis != null && lis.size() > 0) {
			if (lis.size() > 1) {
				msg = "条件重复，请用其他条件查询!";
				mm.put("vehicle", null);
			} else {
				Vehicle  cus=Vehicle.dao.findById(lis.get(0).get(Vehicle.column_ids));
				mm.put("vehicle", cus);
			}
		} else {
			msg = "信息不存在，请重新输入查询条件！";
		}
		mm.put("msg", msg);
		return mm;
	}
	
	/**
	 * 保存顾客登记信息
	 */
	public RenderBean saveInfo(FineRegistration fineRegistration) {
		RenderBean result = new RenderBean();
		String msg = "保存成功";
		if(fineRegistration.getStr(FineRegistration.column_VID)!=null&&!fineRegistration.getStr(FineRegistration.column_VID).equals("")){
			if(!fineRegistration.save()){
				msg = "服务器异常，保存失败！";
			}
		}else{
			msg = "车辆信息不能为空！";
		}
		result.getMap().put("msg", msg);
		return result;

	}
	
	}
	


